package com.zhu.transaction.mapper.imp;

import com.zhu.transaction.mapper.UserMapper;
import com.zhu.transaction.pojo.User;
import com.zhu.transaction.pojo.reports.UserReports;
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author Zhu
 * @createtime 2021/1/7-18:53
 */
@Repository
public class UserMapperImp implements UserMapper {

    @Autowired
    SqlSession sqlSession;


    @Override
    public int addUser(User user) {
        return sqlSession.getMapper(UserMapper.class).addUser(user);
    }

    @Override
    public List<User> queryAllUser(Boolean isAdmin) {
        return sqlSession.getMapper(UserMapper.class).queryAllUser(isAdmin);
    }

    @Override
    public User queryUserByUsername(String username) {
        return sqlSession.getMapper(UserMapper.class).queryUserByUsername(username);
    }

    @Override
    public User queryUserByID(String userID) {
        return sqlSession.getMapper(UserMapper.class).queryUserByID(userID);
    }

    @Override
    public User queryUserByPhone(String phone) {
        return sqlSession.getMapper(UserMapper.class).queryUserByPhone(phone);
    }

    @Override
    public User queryUserByUsernameAndPassword(String username, String password) {
        return sqlSession.getMapper(UserMapper.class).queryUserByUsernameAndPassword(username, password);
    }

    @Override
    public int updateUserInfo(User user) {
        return sqlSession.getMapper(UserMapper.class).updateUserInfo(user);
    }

    @Override
    public int updateUserType(String userId, Integer type) {
        return sqlSession.getMapper(UserMapper.class).updateUserType(userId, type);
    }

    @Override
    public int updateUserState(String userId, Integer type) {
        return sqlSession.getMapper(UserMapper.class).updateUserState(userId, type);
    }

    @Override
    public List<UserReports> queryUserReports() {
        return sqlSession.getMapper(UserMapper.class).queryUserReports();
    }
}
